package com.azxcrm.project.system.basic.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.azxcrm.common.utils.StringUtils;
import com.azxcrm.project.system.basic.dao.ICustomerBackgroundDao;
import com.azxcrm.project.system.basic.domain.CustomerBackground;
import com.azxcrm.project.system.basic.service.ICustomerBackgroundService;

/**
 * 客户背景类型 服务层实现
 * 
 * @author Dustyone
 * @date 2018-08-28
 */
@Service
public class CustomerBackgroundServiceImpl implements ICustomerBackgroundService 
{
	@Autowired
	private ICustomerBackgroundDao customerBackgroundDao;
	
	/**
     * 查询客户背景类型信息
     * 
     * @param backgId 客户背景类型ID
     * @return 客户背景类型信息
     */
	 @Override
	public CustomerBackground selectCustomerBackgroundById(Integer backgId)
	{
	    return customerBackgroundDao.selectCustomerBackgroundById(backgId);
	}
	
	/**
     * 查询客户背景类型列表
     * 
     * @param customerBackground 客户背景类型信息
     * @return 客户背景类型集合
     */
	 @Override
	public List<CustomerBackground> selectCustomerBackgroundList(CustomerBackground customerBackground)
	{
	    return customerBackgroundDao.selectCustomerBackgroundList(customerBackground);
	}
	
    /**
     * 新增客户背景类型
     * 
     * @param customerBackground 客户背景类型信息
     * @return 结果
     */
	 @Override
	public int insertCustomerBackground(CustomerBackground customerBackground)
	{
	    return customerBackgroundDao.insertCustomerBackground(customerBackground);
	}
	
	/**
     * 修改客户背景类型
     * 
     * @param customerBackground 客户背景类型信息
     * @return 结果
     */
	 @Override
	public int updateCustomerBackground(CustomerBackground customerBackground)
	{
	    return customerBackgroundDao.updateCustomerBackground(customerBackground);
	}
	
	/**
     * 保存客户背景类型
     * 
     * @param customerBackground 客户背景类型信息
     * @return 结果
     */
	 @Override
	public int saveCustomerBackground(CustomerBackground customerBackground)
	{
	    Integer backgId = customerBackground.getBackgId();
		int rows = 0;
		if (StringUtils.isNotNull(backgId))
        {
		    rows = customerBackgroundDao.updateCustomerBackground(customerBackground);
		}
		else
        {
		    rows = customerBackgroundDao.insertCustomerBackground(customerBackground);
		}
		return rows;
	}
	
	/**
     * 删除客户背景类型信息
     * 
     * @param backgId 客户背景类型ID
     * @return 结果
     */
	 @Override
	public int deleteCustomerBackgroundById(Integer backgId)
	{
	    return customerBackgroundDao.deleteCustomerBackgroundById(backgId);
	}
	
	/**
     * 批量删除客户背景类型对象
     * 
     * @param backgIds 需要删除的数据ID
     * @return 结果
     */
	 @Override
	public int batchDeleteCustomerBackground(Integer[] backgIds)
	{
		return customerBackgroundDao.batchDeleteCustomerBackground(backgIds);
	}
	
}
